package com.hyzh.latte.hj.config;

import com.coffee.concurrent.CoffeeExecutorManager;
import com.hyzh.latte.hj.service.LatteInitializeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @author songkui
 * @since 2024/6/12
 */
@Component
@Order
@Slf4j
public class HJStartInitialize implements ApplicationRunner {

    private final LatteInitializeService latteInitializeService;

    public HJStartInitialize(LatteInitializeService latteInitializeService) {
        this.latteInitializeService = latteInitializeService;
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        start();
    }


    public void start() throws Exception {
        CoffeeExecutorManager.getInstance().disruptor(8);
        latteInitializeService.initialize();
    }



}
